package com.longyi.service.impl;

import cn.hutool.core.date.DatePattern;
import com.longyi.entity.UserVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longyi.mapper.UserMapper;
import com.longyi.entity.User;
import com.longyi.service.UserService;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public boolean add(UserVO userVO) {
        User user = new User();
        BeanUtils.copyProperties(userVO,user);
        DateTimeFormatter df = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN).withZone(ZoneId.systemDefault());
        LocalDateTime registerTime = LocalDateTime.parse(userVO.getRegisterTime() + " 00:00:00",df);
        user.setRegisterTime(registerTime);
        baseMapper.insert(user);
        return true;
    }
}


